<?php

namespace app\api\controller;

use app\common\controller\Api;
use app\common\model\hotel\Order as OrderModel;

/**
 * 酒店三方接口
 */
class Thirdhotelorder extends Api
{
    //protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    //验单
    public function check()
    {
        $param = input();
        $hotel = new OrderModel();

        $res = $hotel->order_check($param);
        $this->success('',$res['data']);
    }

    //订单提交
    public function create()
    {
        try {
            $param = input();
            $hotel = new OrderModel();
            $param['user_id'] = $this->auth->id;
            $res = $hotel->order_commit($param);
        } catch (\Exception $e) {
            $this->error($e->getMessage());
        }
        $this->success('',$res);
    }

    //取消订单
    public function cancel()
    {
        try {
            $hotel_id = input('hotel_id',0);
            $ota_order_id = input('ota_order_id',0);
            $hotel = new OrderModel();

            $res = $hotel->order_cancel($hotel_id,$ota_order_id);
        } catch (\Exception $e) {
            $this->error($e->getMessage());
        }

        $this->success('取消成功',$res);
    }

    //删除订单
    public function delete()
    {
        try {
            $hotel_id = input('hotel_id',0);
            $son_order_id = input('son_order_id',0);
            $parent_order_id = input('parent_order_id',0);
            $hotel = new OrderModel();

            $res = $hotel->delete_order($hotel_id,$son_order_id,$parent_order_id);
        } catch (\Exception $e) {
            $this->error($e->getMessage());
        }

        $this->success('',$res);
    }

    //订单详情
    public function detail()
    {
        $hotel_id = input('hotel_id',0);
        $parent_order_id = input('parent_order_id',0);
        $hotel = new OrderModel();

        $res = $hotel->order_detail($hotel_id,$parent_order_id);
        $this->success('',$res);
    }



}